/*
 * @FilePath: /hash-guess-game/vite.base.config.ts
 * 介绍:无论哪个环境都会执行的配置项
 */

import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import path from "path";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { VantResolver } from "unplugin-vue-components/resolvers";
import viteCompression from "vite-plugin-compression";

export default defineConfig({
  base: "./",
  resolve: {
    alias: {
      "@@": path.join(__dirname, "src"),
      "@@router": path.join(__dirname, "src/router/index"),
      "@@defaHttp": path.join(__dirname, "src/utils/defaHttp/index"),
    },
  },

  plugins: [
    vue(),
    AutoImport({
      // 自动导入 Vue 相关函数，如：ref, reactive, toRef 等
      imports: ["vue", "vue-i18n", "vue-router", "pinia"],
      dts: "./types/dts/auto-import/imports.d.ts",
    }),
    Components({
      dirs: ["src/components"],
      deep: true,
      extensions: ["vue"],
      dts: "./types/dts/auto-import/components.d.ts",
      resolvers: [VantResolver()],
    }),
    viteCompression({
      verbose: true,
      disable: false,
      threshold: 10240,
      algorithm: "gzip",
      ext: ".gz",
    }),
  ],
});
